#include <iostream>

#include <uiFactory.h>

using namespace lgb_gtk;

int f(void *data)
{
  Window *a = (Window*)data;
  std::cout<<"--------你关闭了窗口！-------\n";
  a->Hide();
  gtk_main_quit();
  return 0;
}

int mouseOut(void *data)
{
  std::cout<<"鼠标移走了\n";
  return 0;
}

int mouseOver(void *data)
{
  std::cout<<"鼠标移到上面了\n";
  return 0;
}

int mouseClicked(void *data)
{
  std::cout<<"鼠标点击了\n";
  Button *b = (Button*)data;
  b->MoveTo(100,100,1);
  return 0;
}

int moveComplete(void *data)
{
  std::cout<<"移动完毕！\n";
  return 0;
}

int main(int argc, char **argv)
{

  gtk_init(&argc, &argv);

  Window *a = UIFactory::GetInstance()->CreateWindow(WINDOW_NORMAL);
  a->SetSize(400,500);
  a->SetTitle("测试窗口");
  a->AddCloseEventListener(f, a);
  a->Show();
  
  Canvas *b = UIFactory::GetInstance()->CreateCanvas(CANVAS_NORMAL);
  a->AddChild(b);
  b->SetBackground("../../ldpim-code/design/images/login2.png");
  //a->AddChild(b);

  Button *c = UIFactory::GetInstance()->CreateButton(BUTTON_IMAGE);
  string bg = "../../ldpim-code/code/res/ui/login_submit_bg.png";
  string ig = "../../ldpim-code/code/res/ui/exit_bg.png";
  string cg = "../../ldpim-code/code/res/ui/login_icon.png";
  c->SetPosition(100,100);
  c->SetImages(bg,ig,cg);
  c->AddMouseOverFunction(mouseOver,NULL);
  c->AddMouseDownFunction(mouseClicked,c);
  c->AddMouseOutFunction(mouseOut,NULL);
  c->AddMoveCompleteFunction(moveComplete,NULL);
  b->AddChild(c);
  
  gtk_main();

  return 0;
}
